var tree = [];
var r = 5;

function setup() {
    createCanvas(800, 800);

    tree[0] = createVector(width / 2, height / 2);
}

function draw() {
    var i = 0;
    background(0);

    var walker = createVector(random(width), random(height));
    var stuck = false;

    while (!stuck){
        for (i = 0; i < tree.length; i++) {
            var d = p5.Vector.dist(walker, tree[i]);
            if (d < r * 2) {
                stuck = true;
                break;
            }
        }
        var vel = p5.Vector.random2D();
        walker.add(vel);
        walker.x = constrain(walker.x, 0, width);
        walker.y = constrain(walker.y, 0, height);
    }

    tree.push(walker);


    for (i = 0; i < tree.length; i++) {
        strokeWeight(r * .5);
        stroke(255);
        point(tree[i].x, tree[i].y);
    }
}